package com.gbx.ximalayating.fragment;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.gbx.ximalayating.R;
import com.gbx.ximalayating.adapter.SubscriptionViewPagerAdapter;

import java.util.ArrayList;
import java.util.List;


public class SubscriptionTingFragment extends Fragment {
    private List<Fragment> fragments;
    private String[] titles=new String[]{"推荐","订阅","历史"};
    public SubscriptionTingFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_subscription, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        fragments=new ArrayList<>();
        fragments.add(new SubscriptionRecommendFragment());
        fragments.add(new SubscriptionTingSubscriptionFragment());
        fragments.add(new HistoryFragment());
        ViewPager pager = (ViewPager) view.findViewById(R.id.subscription_pager);
        pager.setAdapter(new SubscriptionViewPagerAdapter(getFragmentManager(), fragments, titles));
        TabLayout tabLayout = (TabLayout) view.findViewById(R.id.subscription_tab);
        tabLayout.setupWithViewPager(pager);
    }
}
